import time
from machine import PWM, FPIOA

# 配置排针引脚号26，芯片引脚号为61的排针复用为PWM通道1输出
pwm_io = FPIOA()
pwm_io.set_function(61, FPIOA.PWM1)

# 初始化PWM参数
pwm = PWM(1, 2000, 50, enable=True)  # 默认频率2kHz,占空比50%

# 获取当前占空比
current_duty = pwm.duty()
print("当前占空比为：", current_duty, "%")

pwm.duty(75)  # 设置占空比为75%
current_duty = pwm.duty()  # 获取新的占空比
print("当前占空比为：", current_duty, "%")
